home *** CD-ROM | disk | FTP | other *** search
/ Aminet 22 / Aminet 22 (1997)(GTI - Schatztruhe)[!][Dec 1997].iso / Aminet / biz / cloan / pprx_WebAnimDe.lha / pprx_WebAnimDes / WADTransitionMaker.pprx < prev    next >
Text File  |  1997-10-12  |  14KB  |  479 lines

  1. /* Personal Paint Amiga Rexx script - Copyright © 1997, Andres Paabo. */
  2.  
  3. /* $VER:  */
  4.  
  5. /** ENG
  6.  
  7. */
  8.  
  9.  
  10.  
  11. IF ARG(1, EXISTS) THEN
  12.     PARSE ARG PPPORT
  13. ELSE
  14.     PPPORT = 'PPAINT'
  15.  
  16. IF ~SHOW('P', PPPORT) THEN DO
  17.     IF EXISTS('PPaint:PPaint') THEN DO
  18.         ADDRESS COMMAND 'Run >NIL: PPaint:PPaint'
  19.         DO 30 WHILE ~SHOW('P',PPPORT)
  20.              ADDRESS COMMAND 'Wait >NIL: 1 SEC'
  21.         END
  22.     END
  23.     ELSE DO
  24.         SAY "Personal Paint could not be loaded."
  25.         EXIT 10
  26.     END
  27. END
  28.  
  29. IF ~SHOW('P', PPPORT) THEN DO
  30.     SAY 'Personal Paint Rexx port could not be opened'
  31.     EXIT 10
  32. END
  33.  
  34. ADDRESS VALUE PPPORT
  35. OPTIONS RESULTS
  36. OPTIONS FAILAT 10000
  37.  
  38.  
  39. /****THE ABOVE MERELY COPIES PPAINT PPRX START-UP SCRIPT (c)Cloanto*********/
  40. drawrect = getclip('drawrect')
  41. if drawrect~="" then DO
  42.     CLEARIMAGE
  43.     FREEENVIRONMENT FORCE
  44.     SWITCHENVIRONMENT
  45.         END 
  46. /*the above identifies previous use of WEBANIMDESIGNER and clears screens*/
  47.  
  48. openWAD= getclip('openWAD');if openWAD = "" then DO
  49. /********ENSURES SCREEN NOT TOO SMALL & STUFF IS WITHIN SCREEN**************/
  50. accept = 0
  51. GET 'SCREENW'
  52. scw = result
  53. if scw >= 640 then DO
  54.     GET 'SCREENH'
  55. sch = result
  56.     if sch >= 400 then DO
  57.         GET 'IMAGEW'
  58.             imgw = result
  59.             if imgw <= scw then DO
  60.             GET 'IMAGEH'
  61.             imgh = result
  62.                 if imgh <= sch then accept = 1
  63. END
  64. END
  65. END
  66. if accept = 0 then  DO
  67.     Requestnotify 'TITLE "CHANGE SCREEN or IMAGE SIZE" PROMPT  "For viewability, screen size must be 640x 400 or greater, and image size equal or less the screen size"'
  68.     EXIT 0
  69.     END
  70. /********/
  71. TITLEPAGE:
  72.  
  73. Clearimage
  74. GET 'IMAGEW'
  75. imgw = RESULT
  76. imgmid = TRUNC(imgw/2)
  77. Text 'TEXT "WEB ANIM DESIGNER" "fonts:" "times" "15" "of" "'imgmid'" "40" CENTER'
  78. Text 'TEXT "TRANSITION MAKER v0.90" "fonts:" "times" "24" "of" "'imgmid'" "60" CENTER'
  79. Text 'TEXT "FOR PERSONAL PAINT 7.+ (TM Cloanto)  " "fonts:" "times" "18" "of" "'imgmid'" "90" CENTER'
  80. Text 'TEXT "DESIGN ANIMATED GIFS ON THE AMIGA WITH PERSONAL PAINT 7.+ " "fonts:" "times" "15" "of" "'imgmid'" "110" CENTER'
  81. Text 'TEXT "MAIN TRANSITION DESIGNER SCRIPT BY ANDRES PÄÄBO, COPYRIGHT (c) 1997" "fonts:" "times" "11" "of" "'imgmid'" "135" CENTER'
  82. Text 'TEXT "SAVEANIMGIF.PPRX 1.7 SCRIPT (TACKED TO END IN MODIFIED FORM) IS BY CLOANTO (c) 1997" "fonts:" "times" "11" "of" "'imgmid'" "150" CENTER'
  83. Text 'TEXT "FEATURES" "fonts:" "times" "15" "of" "'imgmid'" "180" CENTER'
  84. Text 'TEXT "-Allows custom creation of image breakup & assembly patterns" "fonts:" "times" "15" "of" "'imgmid'" "200" CENTER'
  85. Text 'TEXT "between successive frames of an animation. While well-suited " "fonts:" "times" "15" "of" "'imgmid'" "220" CENTER'
  86. Text 'TEXT "to creating animated gifs, can be used for any animation." "fonts:" "times" "15" "of" "'imgmid'" "240" CENTER'
  87. Text 'TEXT "-Supports Personal Paint time delay annotations on animbrushes." "fonts:" "times" "15" "of" "'imgmid'" "260" CENTER'
  88. Text 'TEXT "-Supports saving to animated gif via Cloantos SaveAnimGif.pprx script." "fonts:" "times" "15" "of" "'imgmid'" "280" CENTER'
  89. Text 'TEXT "which is added to end of this script, FOR CONVENIENCE ONLY." "fonts:" "times" "15" "of" "'imgmid'" "3000" CENTER'
  90. Text 'TEXT "HELP GUIDE & EXAMPLES:" "fonts:" "times" "15" "of" "'imgmid'" "320" CENTER'
  91. Text 'TEXT "Go to www3.sympatico.ca/paabo/webanimdesigner.html" "fonts:" "times" "15" "of" "'imgmid'" "340" CENTER'
  92. Text 'TEXT "(CLICK SCREEN TO PROCEED)" "fonts:" "times" "15" "of" "'imgmid'" "380" CENTER'
  93.  
  94. WAITFORCLICK
  95. END
  96. /********THE ABOVE IS DONE ONLY AT VERY START********/
  97.  
  98. /****THE NEW SCRIPT BEGINS HERE*****/
  99.  
  100. UnlockGui
  101.  
  102.  
  103. FreeBrush FORCE
  104.  
  105. requestwindow:
  106. /*****create input requester*************/
  107. txt_gad_title = 'WEB ANIM TRANSITION MAKER 0.90 by A.Paabo (c)97'
  108. txt_gad_gridx = 'segments across (2-10)'
  109. txt_gad_gridy = 'segments down (2-10)'
  110. txt_gad_timing = 'transition speed (1/60 units)'
  111. txt_gad_pause = 'pause at end of transition'
  112. txt_gad_doall = 'Do all images in same way'
  113. txt_gad_operation = 'Operation:'
  114. txt_gad_operation0 = '1.OPEN new slides Anbrush'
  115. txt_gad_operation1 = '2.MAKE transition'
  116. /*txt_gad_operation2 = '3.LOAD saved transition'
  117. txt_gad_operation3 = '4.PICK UP as annotated animbrush'
  118. txt_gad_operation4 = '5.MAKE ANIMGIF->Cloanto Saveanimgif'*/
  119. txt1 = 'Enter Web Anim Designer for anbrush pickup or save to Angif'
  120.   XX0 = Getclip('XX0')
  121.      XX1 = Getclip('XX1')
  122.      YY1 = Getclip('YY1')
  123.      YY0 = Getclip('YY0')
  124.  
  125. troperation = getclip('troperation'); if troperation="" then troperation=0
  126. timing = GETCLIP('timing')
  127. if timing = "" then timing = 10
  128. gridx = GETCLIP('gridx')
  129. if gridx = "" then gridx = 3
  130. gridy = GETCLIP('gridy')
  131. if gridy = "" then gridy = 3
  132. pause = GETCLIP('pause')
  133. if pause = "" then pause = 300
  134. doall = Getclip('doall')
  135. if doall = "" then doall = 1
  136. /*************/
  137. Request '"'txt_gad_title'" ' ||,
  138.          ' "INTSTR = ""'txt_gad_gridx'"", 1, 10, 'gridx' ' ||,
  139.         ' INTSTR = ""'txt_gad_gridy'"", 1, 10, 'gridy' ' ||,
  140.  ' INTSTR = ""'txt_gad_timing'"", 1, 1000 , 'timing' ' ||,
  141.                ' INTSTR = ""'txt_gad_pause'"", 1, 1000 , 'pause' ' ||,
  142.                ' CHECK = ""'txt_gad_doall'"", 'doall' '||,
  143.  ' CYCLE = ""'txt_gad_operation'"", 2, 'troperation', 
  144.  ""'txt_gad_operation0'"", ""'txt_gad_operation1'"" ' ||,
  145. 'TEXT = ""'txt1'"" "'
  146.          if rc~=0 then EXIT 0
  147.          if rc = 0 then DO
  148.             gridx = RESULT.1
  149.             gridy = RESULT.2
  150.             timing = RESULT.3
  151.              pause = RESULT.4
  152.               doall = RESULT.5
  153.               troperation = RESULT.6
  154.           
  155.             END
  156. CALL SETCLIP('gridx', gridx)
  157. CALL SETCLIP('gridy', gridy)
  158. CALL SETCLIP('timing' , timing)
  159. CALL SETCLIP('pause' , pause)
  160. CALL SETCLIP('doall' , doall)
  161. CALL SETCLIP('troperation',troperation)
  162.  
  163.  
  164.  
  165.  
  166. If troperation = 0 then call LOADER
  167. /**if troperation = 2 then call loadcust
  168. If troperation = 3 then call PICKUPABRUSH
  169. If troperation = 4 then call PICKUPABRUSH**/
  170.  
  171.  
  172. /*******************MAKE TRANSITION*************/
  173. Getframes
  174. numpics=result
  175.  
  176.  If doall=0 then DO
  177.     RequestResponse 'PROMPT "If the transitions are not done in the same manner, there will be a pause after each for you to either make a new transition or load one. Cancel to think about this..."'
  178. if rc~=0 then EXIT 0
  179. END
  180.  
  181. pics=0
  182. cnt=0
  183. DO FOREVER
  184. if pics = numpics then BREAK
  185. pics = pics + 1
  186. /*doall=0***/
  187.     if doall=0 then DO 
  188.            if pics>1 then setframeposition next
  189.              call customselect
  190.             call dotransition
  191.                 END
  192.          
  193. /**doall=1***/
  194. if doall=1 then DO
  195.     if pics>1 then setframeposition next
  196.     if pics= 1 then call customselect
  197.     call dotransition
  198.        END
  199. END
  200.  
  201.  
  202. Requestnotify 'PROMPT "Done. When run as an anim, you only see a scattering of rectangles. To see the transition, enter Web Anim Designer. Settings required will be transp=0, dispose=0, and optimization=boundaries (These settings will automatically be set in Web Anim Designer if done immediately)"'
  203. call setclip('optimization', 1)
  204. call setclip('transp', 0)
  205. call setclip('dispose', 0)
  206. call setclip('operation',1)
  207.  
  208. play 3
  209.  
  210. EXIT 0
  211.  
  212. /************STAMPS OUT SEGMENTS OF ONE PIC & RETURNS TO ABOVE***********/
  213. dotransition:
  214. SETPEN FOREGROUND 2
  215. Text 'TEXT "DOING IMAGE No.'pics'...." "fonts:" "times" "15" "of" "'middle'" "'YY0-20'" CENTER'
  216. WAIT 1000
  217. UNDO
  218. DO i = 1 to numframes
  219. j=cnt+i  /*originally j-cnt-1+i*/
  220. SetFramePosition j
  221.  
  222. DefineBrush coords.i  'FRAMES' 1
  223. ADDFRAMES 1 AFTER
  224. ClearImage
  225. SetBrushAttributes 'HANDLEX' 0 'HANDLEY' 0
  226. z = LASTPOS(' ', coords.i)
  227. str = DELSTR(coords.i, z)
  228. z3 = LAStPOS(' ', str)
  229. xoyo= DELSTR(str, z3)
  230. PutBrush  xoyo
  231. Setframedelay TICKS timing
  232. END
  233. /******/
  234. cnt = cnt+numframes  /*-1*/
  235. DeleteFrames FROM cnt+1 TO cnt+1 
  236. Setframedelay TICKS pause 
  237. FreeBrush FORCE
  238. RETURN
  239.  
  240. /*********************************************/
  241. LOADER:
  242. CLEARIMAGE
  243. FREEENVIRONMENT FORCE
  244. SWITCHENVIRONMENT 
  245.  
  246. GetBrushAttributes 'FRAMES'
  247. pics = RESULT
  248. IF pics < 2 then DO
  249.  Loadanimbrush
  250. if rc~=0 then EXIT 0
  251. END
  252. GetbrushAttributes 'COLORS'
  253. numcolors = RESULT
  254. Set 'FORCE "COLORS='numcolors'"'
  255. copyenvironment FORCE
  256. Set 'FORCE "TRANSP= 1"'
  257.  
  258. /*******centers animbrush anim******/
  259. GET 'IMAGEW'
  260. imgw = RESULT
  261. GET 'IMAGEH'
  262. imgh = RESULT
  263. imgmid = TRUNC(imgw/2)
  264.  
  265. GetBrushAttributes 'FRAMES'
  266. pics = RESULT
  267. GetBrushAttributes HEIGHT
  268. height = RESULT
  269. GetBrushAttributes WIDTH
  270. width = result
  271. if width > imgw-100 then DO; Requestnotify 'TITLE "ANIMBRUSH TO WIDE" PROMPT "The animbrush is too wide. Use larger screen size"';EXIT 0; END
  272.  
  273. if height > imgh-100 then DO; Requestnotify 'TITLE "ANIMBRUSH TO WIDE" PROMPT "The animbrush is too high. Use larger screen size."'; EXIT 0; END
  274. XX0 = TRUNC((imgw-width)/2)
  275. YY0 = TRUNC((imgh-height)/2)
  276. XX1 = XX0 + width
  277. YY1 = YY0 + height
  278. setbrushhandle UPPERLEFT
  279. UseBrushPalette
  280. GetBrushAttributes 'TRANSPARENCY'
  281.             transp = RESULT
  282.                 IF transp=0 then transpcol = 0
  283.                If transp >0 then DO
  284.                 GetBrushAttributes 'TRANSPARENTCOLOR'
  285.                 transpcol = RESULT
  286.                 setpen 'BACKGROUND' transpcol
  287.                     END
  288. /************CLEAR TO ABRS TRANSP COLOR & STAMP DOWN*************************/
  289. GetBrushInfo 'ANNOTATION'
  290. frame_annot = RESULT
  291. delayannot = 0
  292. loop = -1
  293. delay. = 0
  294. IF WORD(frame_annot, 1) = 'LOOP' & WORD(frame_annot, 3) = 'DELAY' THEN DO
  295. delayannot=1
  296.     loop = WORD(frame_annot, 2)
  297.     IF ~DATATYPE(loop, 'W') THEN
  298.         loop = -1
  299.     DO frm = 1 TO pics
  300.         del = WORD(frame_annot, 3+frm)
  301.         IF DATATYPE(del, 'W') THEN
  302.             delay.frm = del
  303. delay.frm = TRUNC(delay.frm*(60/100))
  304.     END
  305. END
  306. SETPEN 'BACKGROUND' transpcol
  307. ClearImage
  308. ADDFRAMES pics AFTER
  309. DO frm = 1 TO pics
  310. SETFRAMEPOSITION frm
  311. if delayannot=1 then SETFRAMEDELAY delay.frm
  312. if delayannot = 0 then SETFRAMEDELAY 10
  313. SetBrushAttributes 'FRAMEPOSITION' frm
  314. Usebrushpalette
  315. Putbrush XX0 YY0
  316. END
  317.  
  318. SETFRAMEPOSITION 1
  319.             call setclip('pics', pics)
  320.             call setclip('XX0', XX0)
  321.            call setclip('YY0', YY0)    
  322.             call setclip('XX1', XX1)
  323.             call setclip('YY1', YY1) 
  324.             call setclip('openWAD', 1)
  325. call setclip('troperation', 1)   
  326. freebrush  /*not needed as we make the preview version from the image*/
  327.  
  328. PLAY 
  329.  
  330. Requestnotify 'TITLE "PROJECT IS NOW SET UP" PROMPT " NEW PROJECT IS SET UP. This is how the animation looks WITHOUT transition. You may add frames and images, edit, etc. but the transition effect will use the size of the original animbrush. Enter WADTransitionMaker again when ready to proceed."'
  331.  
  332. EXIT 0
  333. /******************************************/ 
  334. customselect:
  335. deftrans = getclip('deftrans'); if deftrans = "" then deftrans=2
  336. txt_gad_title = 'DEFINE TRANSITION TO BE USED NEXT'
  337. txt_gad_deftrans= 'define transition:'
  338. txt_gad_deftrans0= 'repeat last transition'
  339. txt_gad_deftrans1= 'load custom transition'
  340. txt_gad_deftrans2= 'make new transition'
  341. txt_gad_deftrans3= '[!abort process!]'
  342. Request '"'txt_gad_title'" ' ||,
  343.  ' "CYCLE = ""'txt_gad_deftrans'"", 4, 'deftrans', 
  344.  ""'txt_gad_deftrans0'"", ""'txt_gad_deftrans1'"", ""'txt_gad_deftrans2'"", ""'txt_gad_deftrans3'"" "'
  345.          if rc~=0 then EXIT 0
  346.          if rc = 0 then deftrans = RESULT.1
  347. /*******used by texts***/
  348. GET 'IMAGEW'
  349. imgw = RESULT
  350. middle=TRUNC(imgw/2)GET 'IMAGEW'
  351. imgw = RESULT
  352. middle=TRUNC(imgw/2)
  353. /***DETERMINE SEGMENT SIZE & NUMBR OF FRAMES******/   
  354.       wsegment = TRUNC((XX1-XX0)/gridx)
  355.       hsegment = TRUNC((YY1-YY0)/gridy)
  356.      numframes = gridx * gridy
  357.       call setclip('numframes', numframes)
  358. /*************************************************/
  359. if deftrans=2 then DO          
  360. CopyEnvironment
  361. switchEnvironment
  362. ADDFRAMES 2 AFTER
  363. ClearImage
  364. SETPEN FOREGROUND 2
  365.  
  366. A0=XX0
  367. B0=YY0
  368. A1=XX1
  369. B1=YY1
  370. drawline A0 B0 A1 B0 
  371. DrawLine A0 B0 A0 B1 
  372.  
  373. DO Gridx
  374. A0 = A0+wsegment
  375. drawline A0 B0 A0 B1 
  376. END
  377. A0=XX0
  378. B0=YY0
  379. A1=XX1
  380. B1=YY1
  381. DO Gridy
  382. B0 = B0+hsegment
  383. DrawLine A0 B0 A1 B0
  384. END
  385.  
  386. Text 'TEXT "CLICK RECTANGLES IN DESIRED TRANSITION ORDER" "fonts:" "times" "15" "of" "'middle'" "'YY0-20'" CENTER'
  387.  
  388. Unlockgui
  389. Do i = 1 to numframes
  390. SetBrushHandle CENTER
  391. Waitforclick
  392. GetMousePosition
  393. AB = RESULT
  394. z=LASTPOS(' ', AB)
  395. A = LEFT(AB,z)
  396. if A > gridx*wsegment+XX0 then DO; i=i-1;iterate;END
  397. if A < XX0 then DO; i=i-1; iterate;END
  398. A= A-XX0
  399. L=LENGTH(AB)
  400. B=RIGHT(AB,L-z)
  401. if B > gridy*hsegment+YY0 then DO; i= i-1;iterate;END 
  402. if B < YY0 then DO; i= i-1;iterate;END
  403. B=B-YY0
  404. n= TRUNC(A/wsegment)
  405. m = TRUNC(B/hsegment)
  406. xo = n*wsegment
  407. yo = m*hsegment
  408. xo = xo+XX0
  409. yo= yo+YY0
  410. xi = xo + wsegment
  411. yi = yo + hsegment
  412. coords.i = xo yo xi yi
  413. SetFramePosition 2
  414. WAIT 100
  415. Definebrush coords.i
  416. SetFramePosition 1
  417. SetBrushHandle upperleft
  418. PutBrush xo yo
  419. END
  420. FreeEnvironment FORCE QUIET
  421. CLOSE('coordslist')
  422. call setclip('deftrans', deftrans)
  423. RequestResponse 'PROMPT "Save Current Custom Transition?"'
  424. if rc ~=0 then RETURN
  425. if rc = 0 then call savecust
  426. END
  427. if deftrans=1 then DO
  428.     Requestfile 'TITLE "Load Custom Transition"'
  429.     if rc ~=0 then call customselect
  430.     if rc = 0 then DO
  431.     filname= RESULT
  432.     len = LENGTH(filname)
  433.     filname = SUBSTR(filname, 2 , len-2) /*get rid of quotes*/
  434.     openlist = OPEN('coordslist',filname,'R')
  435.     XX0 = READLN('coordslist')
  436.     YY0 = READLN('coordslist')
  437.     XX1 = READLN('coordslist')
  438.     YY1 = READLN('coordslist')
  439.     gridx = READLN('coordslist')
  440.     gridy = READLN('coordslist')
  441.     timing = READLN('coordslist')
  442.     pause = READLN('coordslist')
  443.     numframes = gridx*gridy
  444.         DO i = 1 to numframes
  445.         coords.i = READLN('coordslist')
  446.         END
  447.     CLOSE('coordslist')
  448.     RETURN
  449.     END
  450.     END
  451.  if pics = 1 then DO; if deftrans = 0 then call customselect;END
  452. if pics > 1 then DO; if deftrans = 0 then RETURN; END
  453. if deftrans = 3 then EXIT 0
  454. /*******save custom params***************/
  455. savecust:
  456. Requestfile 'TITLE "Save Current Custom Transition?"'
  457. if rc~=0 then RETURN
  458. filname= RESULT
  459. len = LENGTH(filname)
  460. filname = SUBSTR(filname, 2 , len-2) /*get rid of quotes*/
  461. ADDRESS COMMAND 'Delete 'filname'' FORCE
  462. openfile = OPEN('coordslist',filname,'W')
  463. WRITELN('coordslist', XX0)
  464. WRITELN('coordslist', YY0)
  465. WRITELN('coordslist', XX1)
  466. WRITELN('coordslist', YY1)
  467. WRITELN('coordslist', gridx)
  468. WRITELN('coordslist', gridy)
  469. WRITELN('coordslist', timing)
  470. WRITELN('coordslist', pause)
  471. DO i = 1 to numframes
  472. WRITELN('coordslist',coords.i)
  473. END
  474. CLOSE('coordslist')
  475. RETURN
  476.  
  477.  
  478.  
  479.